/**
 * 图片blob转图片base64
 * @param blob 
 */
export function blobToBase64 (blob) {
	return new Promise((resolve,reject) => {
		const reader = new FileReader();
		reader.readAsDataURL(blob);
		reader.onload = () => {
		  const base64 = reader.result;
		  resolve(base64);
		}
		reader.onerror = error => reject(error);
	  })
}

/**
 * 图片base64转blob
 * @param base64 base64图片
 */
export function base64ToBlob (base64) {
	let bstr = window.atob(base64),
		n = bstr.length,
		u8arr = new Uint8Array(n);
	while (n--) {
		u8arr[n] = bstr.charCodeAt(n)
	}
	return new Blob([u8arr], { type: base64})
}
